/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nanosn.framework.core;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author selkhateeb
 */
public class ExtensionPoint
{

    // <editor-fold defaultstate="collapsed" desc="Private Members">
    private List<Component> components = new ArrayList<Component>();
    private Class implementedInterface;
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Public Methods">
    public Class getImplementedInterface()
    {
        return implementedInterface;
    }

    public List<Component> getComponents()
    {
        return components;
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Constructor">
    private ExtensionPoint()
    {
        //Disable Default Constructor
    }
    public ExtensionPoint(ComponentManager componentManager, Class intrface) throws Exception
    {

        this.implementedInterface = intrface;
        // Get all components that extends the provided interface
        for (Component component : componentManager.getComponents())
        {
            for (Class class1 : component.getClass().getInterfaces())
            {
                if (class1.equals(intrface))
                {
                    this.components.add(component);
                }
            }
        }
    }
    // </editor-fold>
}
